//引入axios
import myaxios from "../myaxios/myaxios";
//登录接口
export const login = (params) =>{
   return  myaxios.post("admin/login", params).catch((err) => console.log(err));
}
// 退出接口
export const logout = () =>{
    return myaxios.get("admin/signout").catch(err=>{console.log(err)})
}
//总的用户量
export const getTotalUser = ()=>{
    return myaxios.get("v1/users/count").catch(err=>{console.log(err)})
}
//食品分类

const foodCategory = (latitude, longitude) => myaxios.get("/shopping/v2/restaurant/category");
export{
    foodCategory,
}
//获取某天的注册量
export const getTodayUser  =(date)=>{
    return myaxios.get("/statis/user/"+date+"/count").catch(err=>{console.log(err)})
}
//总订单量
export const getTotalOrder = ()=>{
    return myaxios.get("bos/orders/count").catch(err=>{
        console.log(err)
    })
}
//获取某天的订单
export const getTodayTotal = (date)=>{
    return myaxios.get("statis/order/"+date+"/count").catch(err=>{console.log(err)})
}
//获取管理员数量
export const getAdminCount = ()=>{
    return myaxios.get("admin/count").catch((err)=>{
        console.log(err)
    })
}
//获取当天管理员数量
export const getTodayAdmin = (date)=>{
    return myaxios.get("/statis/admin/"+date+"/count").catch(err=>{console.log(err)})
}
//获取订单列表
export const getOrderList = (params) => {
    return myaxios.get("bos/orders", {
        params: params,
    })
        .catch((err) => {
                console.log(err)
            })
    }
    //获取订单总数
export const getAllOrders = () => {
        return myaxios.get("/bos/orders/count")
            .catch((err) => {
                console.log(err)
            })
    }
    /* 获取商铺列表的接口 */
export const getShoplist = (params) => {
    return myaxios
        .get("shopping/restaurants", {
            params: {
                latitude: 10,
                longitude: 10,
                ...params,
            },
        })
        .catch((err) => console.log(err));
};
/* 添加商铺接口 */
/* export const addShop = (params) => {
    return myaxios
        .post("shopping/addshop", {
            params:{
                name:" ",
                address:"", 
                phone:"",
                latitude:"",
                longitude:"",
                category :"",
                image_path:"",
                float_delivery_fee:"",
                float_minimum_order_amount:"",
                ...params,
            }
        })
        .catch((err) => console.log(err));
}; */
 export const addShop = data => myaxios.post('/shopping/addShop', data);
/* 获取定位城市 */
export const cityGuess = () =>{
    return myaxios.get("/v1/cities", {
        params: {
          type: "guess",
        },
    });
}


/* 模糊搜索地址接口 */
export const searchPlace = (params) => {
    return myaxios.get("/v1/pois", {
        params: {
            city_id: 11, // 后台 深圳
            type: "search",
            ...params
        }
    })
}

//获取食品列表的接口
export const getFoodlist = () => {
        return myaxios
            .get("shopping/v2/foods", {
                limit: 20,
                offset: 0,
                restaurant_id: 3
            })
            .catch(err => {
                console.log(err);
            })
    }
    //获取食品分类接口
export const getFoodCategory = () => myaxios.get("/shopping/v2/restaurant/category").catch(err => {
        console.log(err);
    })
    //更新商铺
export const updateShop = (params) => {
        return myaxios.post("shopping/updateshop", params).catch(err => {
            console.log(err);
        })
    }
    //获取店铺食品种类接口
export const getFoodType = (data) =>
    myaxios.get("/shopping/v2/menu", {
        params: data,
    });

//删除餐馆信息
export const deleteResturant = (params) => {
    myaxios.delete("shopping/restaurant", params).catch(err => {
        console.log(err);
    })
}

// 获取用户列表接口
export const getUserList = (params) => {
    return myaxios.get("/v1/users/list", { params: params }).catch(err => { console.log(err) })
}
//更新食品
export const updateFood = (data) =>{
    return myaxios.post("/shopping/v2/updatefood",data);
}
//删除食品
export const deleteFood = (food_id) => myaxios.delete("/shopping/v2/food/" + food_id);

// 获取管理员列表接口
export const getAdminList = (params) => {
    return myaxios.get("/admin/all", { params: params }).catch(err => {
        console.log(err)
    })
}
